﻿config.eventcfg = {		
	dataImportParam: function(){
		var pgrid = JxUtil.getParentGrid(this.grid);
        var records = JxUtil.getSelectRows(pgrid);
		if (!JxUtil.selected(records)) return;
        
		var area_name = records[0].get('store_in__in_code');
        var e = encodeURIComponent;
		return {extendParam:'extparam_1='+e(area_name)};
	}
};



config.initpage = function(gridNode){
        var grid = gridNode.page;
    
		//父表格数据判断
		var prec = function(subg, records) {
            if (records.length > 0) return true;
            var pg = JxUtil.getParentGrid(subg);
			var pf = JxUtil.getParentForm(subg);
			var rec = pf.myRecord;
			if (!rec || !rec.get('store_in__in_code')) {
				JxHint.alert('没有找到当前表单数据对象！');
				return false;
			}
			pg.getStore().insert(0, rec);
			pg.getSelectionModel().selectFirstRow();
			
			records[0] = rec;
			return true;
		};
    	
        var calu = function(record, field1, field2, field3) {
            var value = record.get(field1) * record.get(field2);
            record.set(field3, value);
        };

        grid.on('beforeedit', function(e) {	
            var pg = JxUtil.getParentGrid(grid);
            var records = pg.getSelectionModel().getSelections();
            
            if (!prec(grid, records)) return false;
            
           // alert(records[0]);
            
            
            //alert('beforeedit='+records.length);
        });

        grid.on('afteredit', function(e) {	
            var pg = JxUtil.getParentGrid(grid);
            var records = pg.getSelectionModel().getSelections();
           // alert('afteredit='+records.length);
            
            if (e.field == 'store_indet__in_num') {
                calu(e.record, 'store_indet__in_num', 'store_mat__mat_price', 'store_indet__in_money');
            }
        });

    };
